/*
 * @Description: 因子库列表
 * @Author: chenju
 * @Date: 2022-01-19 10:47:42
 * @LastEditors: qingyang
 * @LastEditTime: 2023-01-04 10:15:09
 */

import { get, post } from '@/utils/http'
import type { BasicPagingListParams, BasicPagingListResult } from '@/apis/basicModel'
import type {
  IApprovalFactorParams,
  IApprovalFactorResult,
  IApprovalSubmit,
  IFactorDetail,
  IHistory
} from './model/auditModel'

enum Api {
  GET_FACTOR_LIST = '/footprint/manager/pageApprovalFactor',
  SUBMIT_FACTOR = '/footprint/manager/approvalFactor',
  GET_NUM = '/footprint/manager/getWaitApprovalNum',
  QUERY_FACTOR_DETAIL = '/footprint/factor/getByFactorNo',
  QUERY_AUDIT_FACTOR_DETAIL = '/footprint/manager/getApprovalFactorDetail',
  GET_HISTORY = '/footprint/manager/getApprovalHistory'
}

// 分页查询审核因子
export const getApprovalFactorList = (
  params: IApprovalFactorParams & BasicPagingListParams
): Promise<BasicPagingListResult<IApprovalFactorResult>> => get(Api.GET_FACTOR_LIST, params)

// 统计待审核因子数
export const getWaitApprovalNum = (): Promise<number> => get(Api.GET_NUM)

// 提交审核
export const submitAudit = (params: IApprovalSubmit): Promise<void> =>
  post(Api.SUBMIT_FACTOR, params)

// 查看因子详情
export const queryFactorDetail = (factorNo: string): Promise<IFactorDetail> =>
  get(Api.QUERY_FACTOR_DETAIL, { factorNo })
export const queryAuditFactorDetail = (factorNo: string): Promise<IFactorDetail> =>
  get(Api.QUERY_AUDIT_FACTOR_DETAIL, { factorNo })

// 获取因子审核操作历史
export const getApprovalHistory = (factorNo: string): Promise<IHistory[]> =>
  get(Api.GET_HISTORY, { factorNo })
